all files / applications/hirlevel/ hirlevel.js

5.88% Statements 2/34
0% Branches 0/10
0% Functions 0/15
5.88% Lines 2/34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97                                                                                                                                                                                             
import template from './feliratkozas.pug';
import popupTemplate from './feliratkozas-popup.pug';
import sikeresFeliratkozasPopupTemplate from './sikeres-feliratkozas-popup.pug';
import sikeresLeiratkozasPopupTemplate from './sikeres-leiratkozas-popup.pug';
import sikertelenPopupTemplate from './sikertelen-popup.pug';
import hirlevelService from './hirlevel-service';
const MODULE_NAME = 'hirlevel';
class HirlevelController {
	constructor(hirlevelService, $scope, $uibModal, $location) {
		'ngInject';
		this._hirlevelService = hirlevelService;
		this._$scope = $scope;
		this._$uibModal = $uibModal;
		this._$location = $location;
	}
	_showPopup() {
		this._$uibModal.open({
			animation: true,
			template: popupTemplate()
		});
	}
	_showSikeresFeliratkozasPopup() {
		this._$uibModal.open({
			animation: true,
			template: sikeresFeliratkozasPopupTemplate()
		});
	}
	_showSikeresLeiratkozasPopup() {
		this._$uibModal.open({
			animation: true,
			template: sikeresLeiratkozasPopupTemplate()
		});
	}
	_showSikertelenPopup() {
		this._$uibModal.open({
			animation: true,
			template: sikertelenPopupTemplate()
		});
	}
	$onInit() {
		this.model = {};
		this.captchaUrl = this._getCaptchaUrl();
		if (this._$location.search().megerositesToken) {
			this._hirlevelService.megerosites(this._$location.search().megerositesToken).then(() => {
				this._showSikeresFeliratkozasPopup();
			}, () => {
				this._showSikertelenPopup();
			});
		}
		if (this._$location.search().leiratkozasToken) {
			this._hirlevelService.leiratkozas(this._$location.search().leiratkozasToken).then(() => {
				this._showSikeresLeiratkozasPopup();
			}, () => {
				this._showSikertelenPopup();
			});
		}
	}
	_captchaFrissites() {
		this.captchaUrl = this._getCaptchaUrl();
	}
	_getCaptchaUrl() {
		return this._hirlevelService.getCaptchaUrl();
	}
	kuldes(e) {
		e.preventDefault();
		this._hirlevelService.kuldes(this.model, this.captcha).then(() => {
			this._captchaFrissites();
			this.model = {};
			this.captcha = '';
			this._showPopup();
			this.errors = null;
		}, (err) => {
			if (err.status && err.status == 400 && err.data && err.data.errors) {
				this.errors = err.data.errors;
			} else {
				this.technikaiHiba = true;
			}
			this._captchaFrissites();
			this.captcha = '';
		});
	}
}
 
angular.module(MODULE_NAME, [hirlevelService])
	.component('hirlevel', {
		controller: HirlevelController,
		template: template(),
		bindings: {
			wide: '<'
		}
	});
 
export default MODULE_NAME;